WTL Controls
Back to the WTL Controls Home Page.
BIS_WTL_CONTROLS::CHyperlinkImage Class Reference

A CStatic descendant providing a context menu with a single entry, allowing the launch of the default browser to a pre - defined URL. More...

#include <HyperlinkImage.h>

Inheritance diagram for BIS_WTL_CONTROLS::CHyperlinkImage:

Public Member Functions

 CHyperlinkImage () noexcept
 
virtual ~CHyperlinkImage ()
 
void SubclassStatic (HWND hWnd)
 Subclass a Static TExt control window. More...
 
void UnSubclassStatic ()
 Un-subclass the window. More...
 
void SetURL (std::basic_string< TCHAR > url)
 Load a new target URL More...
 
std::basic_string< TCHAR > GetURL () const
 Default: "". More...
 
void SetMenuText (std::basic_string< TCHAR > text)
 Load text to be displayed in the context menu item. More...
 
std::basic_string< TCHAR > GetMenuText () const
 Default: "". More...
 

Detailed Description

A CStatic descendant providing a context menu with a single entry, allowing the launch of the default browser to a pre - defined URL.

This class is intended for use with the 'PictureBox' control found in the VC++ Dialog Editor toolbox. (This is, of course, a static text control with one of the relevant window styles (e.g, SS_BITMAP, SS_ICON) set.) The inherited CStatic::SetIcon, CStatic::SetBitmap, etc, member functions can be used to load an image.

Usage is a bit complicated. You have to add the following menu definition to the client project .rc file:

BEGIN
POPUP ""
BEGIN
MENUITEM "Visit a Web Site", IDM_HYPERLINKIMAGE_LINK
END
END

In addition, you must manually modify the client project .rc file TEXTINCLUDE2 resource to include the wtl_controls_resources.h file, as this is where the menu and command resource values are defined; e.g.,

"#include ""c:\\somepath\\wtl controls\\include\\wtl_controls_resource.h""\r\n"

Assuming all this has been done, typical usage is depicted below.

CHyperlinkImage m_LinkImage;
m_LinkImage.SubclassStatic(GetDlgItem(IDC_PICBOX));
m_LinkImage.SetMenuText(_T("Lets see if this works."));
m_LinkImage.SetURL(_T("http:\\\\somesite.com"));
.
.
.
m_LinkImage.UnSubclassStatic(); // when finished using the control (probably in OnEndDialog).

Definition at line 61 of file HyperlinkImage.h.

Constructor & Destructor Documentation

◆ CHyperlinkImage()

BIS_WTL_CONTROLS::CHyperlinkImage::CHyperlinkImage ( )
noexcept

Definition at line 20 of file HyperlinkImage.cpp.

◆ ~CHyperlinkImage()

BIS_WTL_CONTROLS::CHyperlinkImage::~CHyperlinkImage ( )
virtual

Definition at line 25 of file HyperlinkImage.cpp.

Member Function Documentation

◆ SubclassStatic()

void BIS_WTL_CONTROLS::CHyperlinkImage::SubclassStatic ( HWND  hWnd)

Subclass a Static TExt control window.

The SS_NOTIFY flag is added to the control's window styles, as well.

Parameters
hWndThe handle of the static text control window to be subclassed.
Return values
void

Definition at line 41 of file HyperlinkImage.cpp.

◆ UnSubclassStatic()

void BIS_WTL_CONTROLS::CHyperlinkImage::UnSubclassStatic ( )

Un-subclass the window.

Return values
void

Definition at line 56 of file HyperlinkImage.cpp.

◆ SetURL()

void BIS_WTL_CONTROLS::CHyperlinkImage::SetURL ( std::basic_string< TCHAR >  url)

Load a new target URL

Parameters
urlThe new target URL.
Return values
void

Definition at line 71 of file HyperlinkImage.cpp.

◆ GetURL()

std::basic_string< TCHAR > BIS_WTL_CONTROLS::CHyperlinkImage::GetURL ( ) const

Default: "".

Returns the target URL; i.e., the URL the default browser will launch to when the context menu item is clicked.

Return values
std::basic_string<TCHAR>

Definition at line 84 of file HyperlinkImage.cpp.

◆ SetMenuText()

void BIS_WTL_CONTROLS::CHyperlinkImage::SetMenuText ( std::basic_string< TCHAR >  text)

Load text to be displayed in the context menu item.

Parameters
textNew menu item text.
Return values
void

Definition at line 99 of file HyperlinkImage.cpp.

◆ GetMenuText()

std::basic_string< TCHAR > BIS_WTL_CONTROLS::CHyperlinkImage::GetMenuText ( ) const

Default: "".

Returns the text to be displayed in the context menu item.

Return values
std::basic_string<TCHAR>The menu item text.

Definition at line 112 of file HyperlinkImage.cpp.


The documentation for this class was generated from the following files: